package com.gsi.multichannel.sf.pipelet;

import com.intershop.beehive.core.capi.naming.NamingMgr;
import com.intershop.beehive.core.capi.pipeline.Pipelet;
import com.intershop.beehive.core.capi.pipeline.PipelineDictionary;
import com.intershop.beehive.core.capi.domain.Domain;
import com.training.capi.BoxManager;

/**
 * 
 */
public class CreateBox extends Pipelet
{

    /**
     * Constant used to access the pipeline dictionary with key 'name'
     */
    public static final String DN_NAME = "name";

    public static final String DN_DOMAIN = "domain";
    private BoxManager manager;
    public int execute(PipelineDictionary dict)
    {    
        // lookup 'domain' in pipeline dictionary
        Domain domain = dict.getOptional(DN_DOMAIN);
        
        // lookup 'name' in pipeline dictionary
        String name = dict.getOptional(DN_NAME);
        manager = (BoxManager)NamingMgr.getInstance().lookupManager(BoxManager.REGISTRY_NAME);
        manager.putBoxPO(domain, name);

        return PIPELET_NEXT;
    }
}